<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="author" content="wangbo">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>state </title>
</head>

<body>
    <div id="app" ></div>
    <script src="../js/react.development.js"></script>
    <script src="../js/react-dom.development.js"></script>
    <!-- 专门设置props的库 -->
    <script src="../js/prop-types.js"></script>
    <script src="../js/babel.min.js"></script>
    <script type="text/babel">
        // vue里边的data 60% react 30$ anguler 微信小新程序,
        // 只能是class 使用 func
        // a new vue  a.data/this.data,不允许直接的修改
        class MyData extends React.Component {
            constructor(props) {
                super(props)
                this.chg =this.chg.bind(this)
                // 和vue的data,一旦被定义不许随意修改,想修改,需要用setState 的方法
                this.state={
                    msg:'我是信息'
                }
            }
            chg(){
                this.setState({
                    msg:"我被修改了"
                })
            }
            render() {
                return [
                    // 强制的改变了,当前元素的text的值,并没有修改state的值
                    <div key='1' onClick={this.chg} >{this.state.msg} </div>,                   
                    
                    <span key='2'> {this.state.msg}</span>
                ]
            }
        }
        ReactDOM.render(<MyData />, document.getElementById('app'))
    </script>
</body>

</html>